#!/usr/bin/env node

console.log(`I'm Father process: ${process.pid}`);

const cp = require('child_process');


process.on('message',(data) => {
  console.log(`I have child: ${data}`);
});

let son = cp.fork('./11-ipc-child.js'),
    dau = cp.fork('./11-ipc-child.js');


setTimeout(() => {
  son.send('赶紧滚蛋');
},2000);

setTimeout(() => {
  dau.send('赶快回来');
},3000);

setTimeout(() => {
  son.kill('SIGINT');
  dau.kill('SIGINT');
},5000);

//虽然父子进程分离，但是父进程可以控制子进程的存在
